package sifeap.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidadorExpresiones {
	private static Pattern pattern;
	private static Matcher matcher;
	
	//Expresion regular para validar correo electronico
	public static final String EMAIL = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
	
	/**
	 * Valida si <code>valor</code> contra la expresion regular <code>expresion</code>
	 * @param expresion Expresion regular
	 * @param valor Valor a validar
	 * @return
	 */
	public static boolean validar(String expresion, String valor) {
		pattern = Pattern.compile(expresion);
		matcher = pattern.matcher(valor);
		return matcher.matches();
	}
}
